package Operation;

import bookk.Book;
import bookk.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    /**
     * @param booklist
     */
    @Override
    public void work(BookList booklist) {
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入要归还的书籍");
        String name = sc.nextLine();
        int size = booklist.getUsesize();
        int i=  0;
        for ( i = 0; i < size; i++) {
            Book book = booklist.getBooks(i);
            if(book.getName().equals(name)){
                book.setBorrowed(false);
                System.out.println("归还成功");
                System.out.println(book);
                return;
            }
        }
        System.out.println("你要归还的书不存在");

    }
}
